package com.wsd.bookkeeping.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wsd.bookkeeping.entity.Account;
import com.wsd.bookkeeping.form.TransferForm;
import com.wsd.bookkeeping.vo.*;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

@Mapper
public interface AccountMapper extends BaseMapper<Account> {

    @MapKey("userId")
    List<Map<String, Object>> queryUserListByBookId(Integer bookId);
    AccountAdminVO queryAccountAdminByBookId(Integer bookId);

    List<LedgerUserInfo> queryUserInfoListByBookId(Integer bookId);

    /**
     * 根据id查询用户自己创建的账本列表
     * @param userId
     * @return
     */
    List<AccountVO> queryAccountListOfSelf(@Param("userId") Integer userId, @Param("size") Integer size);

    /**
     * 根据id查询用户加入的账本列表
     * @param userId
     * @return
     */
    List<AccountVO> queryAccountListOfJoin(@Param("userId") Integer userId, @Param("size") Integer size);

    /**
     * 根据账本Id查询账本使用者信息
     * @param bookId 账本Id
     * @return
     */
    List<AccountUserVO> queryAccountBookUserListByBookId(Integer bookId);

    /**
     * 查询用户当前月的
     * 记账次数
     * 记账总额
     * @param userId
     * @param bookId
     */
    UserCurrentRecord queryUserCurrentRecordInfo(@Param("userId") Integer userId, @Param("bookId") Integer bookId);

    Integer transferAuthority(TransferForm form);

    Integer saveTransferAuthorityLog(TransferForm form);
}
